package acwing._2LanQiao._5BinaryIndexedTree_SegmentTree;
/**
 * @Project : ProgrammingExercises
 * @Package : ACWing._2LanQiao
 * @File : Q1228.java
 * @Author : WangRuoyu
 * @Date : 2023/3/17 16:48
 */

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

class segment {
    int x;
    int y1;
    int y2;
    int k;

    public segment() {
        x = 0;
        y1 = 0;
        y2 = 0;
        k = 0;
    }

    public segment(int x, int y1, int y2, int k) {
        this.x = x;
        this.y1 = y1;
        this.y2 = y2;
        this.k = k;
    }
}

class segmentTree1228 {
    int l;
    int r;
    int cnt;
    int len;

    public segmentTree1228(int l, int r, int cnt, int len) {
        this.l = l;
        this.r = r;
        this.cnt = cnt;
        this.len = len;
    }
}

public class Q1228 {
    static int n;
    static segment[] seg;
    static segmentTree1228[] tree;

    static final int N = 10010;

    static void pushup(int u) {
        if (tree[u].cnt > 0) tree[u].len = tree[u].r - tree[u].l + 1;
        else if (tree[u].r == tree[u].l) {
            tree[u].len = 0;
        } else {
            tree[u].len = tree[u << 1].len + tree[u << 1 | 1].len;
        }
    }

    static void build(int u, int l, int r) {
        tree[u] = new segmentTree1228(l, r, 0, 0);
        if (l == r) return;
        int mid = (l + r) >> 1;
        build(u << 1, l, mid);
        build(u << 1 | 1, mid + 1, r);
    }

    static void modify(int u, int l, int r, int k) {
        if (tree[u].l >= l && tree[u].r <= r) {
            tree[u].cnt += k;
            pushup(u);
        } else {
            int mid = (tree[u].l + tree[u].r) >> 1;
            if (l <= mid) modify(u << 1, l, r, k);
            if (r > mid) modify(u << 1 | 1, l, r, k);
            pushup(u);
        }
    }

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] words = br.readLine().split(" ");

        n = Integer.parseInt(words[0]);
        seg = new segment[2 * n + 1];
        seg[0] = new segment();
        tree = new segmentTree1228[4 * N];

        for (int i = 1; i <= n; ++i) {
            words = br.readLine().split(" ");
            int x1 = Integer.parseInt(words[0]);
            int y1 = Integer.parseInt(words[1]);
            int x2 = Integer.parseInt(words[2]);
            int y2 = Integer.parseInt(words[3]);
            seg[(i << 1) - 1] = new segment(x1, y1, y2, 1);
            seg[i << 1] = new segment(x2, y1, y2, -1);
        }

        Arrays.sort(seg, (o1, o2) -> o1.x - o2.x);

        for (int i = 0; i <seg.length ; ++i) {
            System.out.println(seg[i].x);
            System.out.println(seg[i].y1);
            System.out.println(seg[i].y2);
            System.out.println(seg[i].k);
        }

        build(1, 0, 10000);

        int res = 0;
        for (int i = 1; i <= 2 * n; ++i) {
            if (i > 1) res += (seg[i].x - seg[i - 1].x) * tree[1].len;
            modify(1, seg[i].y1, seg[i].y2 - 1, seg[i].k);
        }
        System.out.println(res);
    }
}

